# -*- coding: utf8 -*-

from google.appengine.ext import db
from google.appengine.ext import webapp
from book.models import *
from book import utils
from book import dao
import logging

class BalancePage(webapp.RequestHandler):
    u"""个人结余维护"""    
        
    def post(self):
        u"""创建店铺"""
        realPay = self.request.get("realPay")
        balancePay = self.request.get("balance")
        key = self.request.get("key")
        balance = Balance.get(db.Key(key))
        if balance:
            balance.realPay = float(realPay)
            balance.balancePay = float(balancePay)
            balance.put()
            logging.getLogger().debug(u'个人结余更新成功： %s' % balance);
            utils.render_to_success(self.response, u'个人结余更新成功')
        else:
            logging.getLogger().debug(u'个人结余不存在')
            utils.render_to_error(self.response, 'balance_e001', u'个人结余更新失败')